package com.thirteengroup.casemg.service.impl;

import com.thirteengroup.casemg.Mapper.accountMapper;
import com.thirteengroup.casemg.service.IAccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.math.BigDecimal;

@Service
public class AccountService implements IAccountService {
    @Autowired
    private accountMapper accountMapper;
    @Override
    @Transactional//相当于是对该方法进行事务增强，事务管理就是增强类
    public void transfer(long id1, long id2, BigDecimal balance) {
        accountMapper.add(id1,balance);
        accountMapper.sub(id2,balance);
    }
}
